//
//  ImageDetailViewController.m
//  TrapDemo
//
//  Created by zkingsoft on 16/2/29.
//  Copyright (c) 2016年 zkingsoft. All rights reserved.
//

#import "ImageDetailViewController.h"

#import "YXVideoKitEngine.h"

@interface ImageDetailViewController ()<YXVideoKitEnginePlayerDelegate>

@property (nonatomic, retain) NSString *videoPath;
@property (nonatomic, retain) YXVideoKitEngine  *videoEngine;



@end

@implementation ImageDetailViewController

- (instancetype)initWithVideoPath:(NSString*)path
{
    self = [super init];
    if (self) {
        self.videoPath = path;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self initPlayer];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    //留意这里，最好调用
    [self.videoEngine clean];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
    //普通播放
    [self.videoEngine applyNormal];
}

- (void)initPlayer
{
    //放置播放器的View
    UIView *playerView = [[UIView alloc] init];
    playerView.frame = CGRectMake(0, 10, self.view.bounds.size.width, self.view.bounds.size.width);
    [self.view addSubview:playerView];
    //初始化引擎
    self.videoEngine = [[YXVideoKitEngine alloc] initWithClips:@[_videoPath] withView:playerView useEffect:NO];//不带效果
    
    //    self.videoEngine = [[YXVideoKitEngine alloc] initWithComponents:@[_videoPath] withView:playerView useEffect:NO];
    
    self.videoEngine.delegate = self;
}



#pragma mark - delegate
- (void)YXVideoKitEnginePlayerDoPlay
{
    self.title = @"播放中";
}

- (void)YXVideoKitEnginePlayerDoPause
{
    self.title = @"暂停中";
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
